﻿@model ClientApp.Models.TransferModel

@{
    ViewBag.Title = "SetAmount";
    Layout = "~/Views/Shared/_Transfer_Menu.cshtml";
}

<h2>Set Amount</h2>
<h2>Transfer from card #@ViewBag.Transfer.FromCardNumber to card #@ViewBag.Transfer.ToCardNumber</h2>

@{
    if (ViewBag.Errors != null)
    {
        <span style="color: red;">@ViewBag.Errors</span>
    }
}
    <p>Please, specify amount and currency you'd like to transfer </p>
    @Html.DropDownListFor(m => m.Currency, new SelectList(@ViewBag.Currencies), new{id = "_currency"})
    @Html.TextBoxFor(m => m.Amount, new { id = "_amount" })
    @Html.ValidationMessageFor(m => m.Amount)
    
    <input type="submit" onclick="return submitTransferForm()" value="Transfer"/>


<script type="text/javascript">
    function submitTransferForm() {
        var amount = $('#_amount').attr('value');
        var currency = $('#_currency').attr('value');
        
        $('#transferForm').attr('action', '/Transfers/Transfer');
        $('#transferForm #amount').attr('value', amount);
        $('#transferForm #currency').attr('value', currency);
        $('#transferForm').submit();
        return false;
    }
</script>